package com.ikaros.concurrency.example.publish;

import com.ikaros.concurrency.annotations.NotRecommend;
import com.ikaros.concurrency.annotations.NotThreadSafe;
import lombok.extern.slf4j.Slf4j;

/**
 * 对象溢出：对象在未完整构造前，不能将其发布
 */
@NotThreadSafe
@NotRecommend
@Slf4j
public class Escape {
    private int ikaros = 0;

    public Escape() {
        new InnerClass();
    }

    //类部类
    public class InnerClass {
        public InnerClass() {
            log.info("ikaros={}", Escape.this.ikaros);
        }
    }

    public static void main(String[] args) {
        new Escape();
    }
}
